#include "CLogo.h"

#include "Enum.h"

#include "Utility.h"
#include "Animation.h"
#include "SpriteMaker.h"


int const SCENE_PLAY_TIME = 3000;

int const BACKGROUND_X = 512;
int const BACKGROUND_Y = -384;

CLogo::CLogo(void)
{
	m_nFinaleTime = 0;
	m_nSceneState = true;
}

CLogo::~CLogo(void)
{
	SharedSpriteMaker.getSprite(eBackgroundTag_Logo)->setPosition(-10000, 10000, eBackgroundTag_Logo);
}

void CLogo::put(void)
{
	SharedSpriteMaker.getSprite(eBackgroundTag_Logo)->setPosition(BACKGROUND_X, BACKGROUND_Y, eBackgroundTag_Logo);
}

void CLogo::setKeyBoardState(int const _nState,int const _nKey)
{
	if(eKeyBoard_Release == _nState)
	{
		m_nSceneState = false;
	}
}

void CLogo::setMouseState(int const _nState, int const _nX, int const _nY)
{
	if(eMouseLeftButton_Release == _nState || eMouseRightButton_Release == _nState)
	{
		m_nSceneState = false;
	}
}

int CLogo::run(void)
{
	m_nNowTime = OgrePlugin_2DRenderer::getPlatformTime();

	if(true == m_nSceneState)
	{
		if(0 == m_nFinaleTime)
		{
			m_nFinaleTime = OgrePlugin_2DRenderer::getPlatformTime() + SCENE_PLAY_TIME;
		}
		else if(0 <= m_nNowTime - m_nFinaleTime)
		{
			return eScene_Main;
		}
	}
	else if(false == m_nSceneState)
	{
		return eScene_Main;
	}
	return eScene_Logo;
}